define([
  "UtilDir/util",
  "UtilDir/tool",
  "UtilDir/dialog",
  "UtilDir/searchBlock",
  "static/app/fwsjcj/xreport/getPcReport",
  'UtilDir/loading',
  "EasyUI", "EasyUI-lang"
], function (Util, Tool, Dialog, SearchBlock, Report, Loading) {
  var sysPath = getServer() + "/static/app/fwsjcj";

  var zwFormHtml = sysPath + "/brick/views/zwForm.html";
  var getZwController = function () {
    return getServer() + "/platform/org/zws/";
  };

  /**
   * 页面初始化
   */
  var init = function () {
    initSearchBlock();
    queryBtnBind();
    createProvince();
    $('input[name="queryType"][value="0"]').attr('checked', true);
    $('#xreports-wrapper').show();
  };

  var initSearchBlock = function () {
    SearchBlock.init("searchBlock");
  };

  var queryBtnBind = function () {
    $('input[type=radio][name=queryType]').change(function () {
      // 获取input radio选中值，方法一
      //var myvalue = $('input:radio[name="queryType"]:checked').val();
      // 获取input radio选中值，方法二
      var myvalue = $(this).val();
      if (myvalue == 0) {
        $("#chooseTask").attr('disabled', true).css({'backgroundColor': 'gray'});
        $("#province").combobox({disabled: false});
        $("#city").combobox({disabled: false});
        $("#county").combobox({disabled: false});
        $('#taskName').prop('disabled', true);
        $('#taskName').val('');
      } else {
        $("#chooseTask").attr('disabled', false).css({'backgroundColor': '#007fff'});
        $('#taskName').prop('disabled', false);
        $("#province").combobox({disabled: true});
        $("#city").combobox({disabled: true});
        $("#county").combobox({disabled: true});
        $('#province').combobox('clear');
        $('#city').combobox('loadData', {});//清空option选项
        $('#city').combobox('clear');
        $('#county').combobox('loadData', {});//清空option选项
        $('#county').combobox('clear');
      }
    });
    var search_loading = Util.loading({
      text: '正在加载'
    })
    // 查询
    $("#btnSearch").click(function () {
      search_loading.show();
      SearchData(search_loading);
    });
    //重置
    $("#btnReset").click(function () {
      $('#province').combobox('clear');
      $('#city').combobox('loadData', {});//清空option选项
      $('#city').combobox('clear');
      $('#county').combobox('loadData', {});//清空option选项
      $('#county').combobox('clear');
      $('#taskName').val('');
      $('#chooseTask').html('请选择')
    });
    // 导出报告
    $("#exportReport").click(function () {
      // if ($('#xreports-contents').css('display') == 'none') {
      //   Util.alert('请先查询报告');
      // } else {
      //   exportXC();
      // }
      exportXC();
    });
    $("#chooseTask").click(function () {
      chooseTask();
    })
  };

  // 选择任务
  var chooseTask = function () {
    var buttons = [];
    buttons.push({
      name: '确定',
      callback: function () {
        //点击确定
        $("#taskName").val($("#TaskGrid").datagrid("getChecked").map(item => item.taskName).join(','))
        $("#chooseTask").html('查看');
        dialog.hide();
      }
    });
    var dialog = Dialog({
      id: "viewTaskDialog",
      cache: false,
      title: '请选择',
      width: "1200px",
      height: "600px",
      body: '<form id="searchForm">\n' +
        '       <div class="row">\n' +
        '          <div class="col-md-4 form-horizontal">\n' +
        '              <div class="form-group">\n' +
        '                 <label for="searchTaskName" class="col-md-4 control-label"> </span>任务名称:</label>\n' +
        '                 <div class="col-md-8">\n' +
        '                    <input id="searchTaskName" type="text" name="searchTaskName" class="form-control">' +
        '                 </div>\n' +
        '              </div>\n' +
        '           </div>' +
        '           <button id="btnTaskSearch" class="btn btn-default" type="button">查询</button>\n' +
        '           <button id="btnTaskReset" class="btn btn-default" type="button">重置</button>' +
        '      </div>' +
        '</form>' +
        '<div id="TaskGrid" idField="taskId"></div>',
      buttons: buttons,
      afterOpen: function () {
        getTaskList();
        $("#btnTaskSearch").click(getTaskList);
        $("#btnTaskReset").click(function () {
          $('#searchTaskName').val('');
          getTaskList()
        });
      }
    });
    dialog.show();
  }
  var getTaskList = function () {
    $("#TaskGrid").datagrid({
      url: getServer() + "/fw/task/page/1",
      method: "GET",
      nowrap: false,
      fitColumns: true,
      autoRowHeight: false,
      columns: [[
        {field: "ck", checkbox: true},
        {field: 'taskNum', title: '任务编号', width: '15%', align: 'center'},
        {
          field: 'taskName', title: '任务名称', width: '21.5%', align: 'center',
          formatter: function (value, rowData, rowIndex) {
            return '<a href="#" onclick="_view(\'' + rowData.taskId + '\',\'' + rowData.groupId + '\',\'' + rowData.taskName + '\',\'' + rowData.status + '\');"> ' + rowData.taskName + ' </a> '
          }
        },
        {field: 'division', title: '任务地区', width: '13%', align: 'center'},
        {field: 'taskManager', title: '任务管理员', width: '9%', align: 'center'},
        {field: 'groupName', title: '承担小组', width: '15%', align: 'center'},
        {field: 'groupLeader', title: '组长', width: '8%', align: 'center'},
        {field: 'groupLeaderMobile', title: '手机号码', width: '10%', align: 'center'},
        {
          field: 'status', title: '任务状态', width: '8%', align: 'center',
          formatter: function (value, rowData, rowIndex) {
            if (value == '0') {
              return '未分配';
            } else if (value == '1') {
              return '进行中';
            } else if (value == '2') {
              return '已完成';
            }
          }
        }
      ]],
      queryParams: {
        taskName: $("#searchTaskName").val()
      },
      pagination: true,
      pageSize: 10,
      onLoadSuccess: function (data) {
        for (var i = 0; i < data.rows.length; i++) {
          if ($("#taskName").val().includes(data.rows[i].taskName)) {
            $('#TaskGrid').datagrid('checkRow', i);
          }
        }
      }
    });
  }

  // 查看任务详情
  var TaskFormHtml = sysPath + "/sifttaskmanage/views/taskForm.html";
  var TaskFormHtmlReadOnly = sysPath + "/sifttaskmanage/views/taskFormReadOnly.html";
  var getTask = function (id) {
    $.ajax({
      url: getServer() + "/fw/task/" + id,
      type: "get",
      success: function (data) {
        Tool.deserialize("taskForm", data);
      }
    });
  };
  window._view = function (taskId, groupId, taskName, status) {
    var taskFormHtml = '';
    if (status == "0") {
      taskFormHtml = TaskFormHtml;
    } else {
      taskFormHtml = TaskFormHtmlReadOnly;
    }
    var slidebar = Util.slidebar({
      url: taskFormHtml,
      width: "580px",
      cache: false,
      close: true,
      afterLoad: function () {
        getTask(taskId);
        //查看队员列表
        $("#viewteamBtn").bind("click", function () {
          var buttons = [];
          buttons.push({
            name: '确定',
            callback: function () {
              //点击确定
              dialog.hide();
            }
          });
          var dialog = Dialog({
            id: "viewTeamDialog",
            cache: false,
            title: '队员情况', //dialog标题
            width: "1000px",
            height: "550px",
            body: '<div id="TeamGrid"></div>',
            buttons: buttons,
            afterOpen: function () {
              $("#TeamGrid").datagrid({
                url: getServer() + "/fw/group/" + groupId,
                method: "GET",
                height: "515px",
                fitColumns: true,
                nowrap: false,
                autoRowHeight: false,
                singleSelect: true,
                columns: [[
                  {field: 'relName', title: '姓名', width: '18%', align: 'center'},
                  {field: 'idNumber', title: '身份证号', width: '28%', align: 'center'},
                  {field: 'mobilePhone', title: '手机号', width: '23%', align: 'center'},
                  {field: 'groupZW', title: '队内职务', width: '15%', align: 'center'},
                  {field: 'formNum', title: '完成表单数量', width: '18%', align: 'center'},
                  /*{field: 'operation', title: '操作', width: '17%', align: 'center',
                      formatter: function (value, rowData, rowIndex) {
                      debugger;
                          return '<a onclick="_viewTrajectory(\'' + rowData.userId+ '\',\'' + taskId+ '\',\'' +taskName+ '\',\'' +rowData.relName+ '\')">查看队员轨迹</a >';
                      }
                  },*/
                ]],

                pagination: false,
                pageSize: 10
              });
            }
          });
          dialog.show();
          window._viewTrajectory = function (userId, taskId, taskName, userName) {
            debugger;
            dialog.hide();
            slidebar.close();
            $('#myTab a[href="#replayMap"]').tab('show');
            //replayInitAll();
            startReplayData(userId, taskId, taskName, userName);
          }
        });
      }
    });
  };

  // 查询
  var SearchData = function (search_loading, cb) {
    var proValue = $('#province').combobox('getText');
    var cityValue = $('#city').combobox('getText');
    var areaValue = $('#county').combobox('getText');
    var taskNameValue = $('#taskName').val();
    var searchValue = {
      belongtoProvince: '',
      belongtoCity: '',
      belongtoArea: '',
      taskName: ''
    }
    searchValue.taskName = taskNameValue;

    if (proValue) {
      // if (cityValue == "全部" || cityValue == '北京市' || cityValue == '天津市' || cityValue == '上海市' || cityValue == '重庆市') {
      if (cityValue == "全部") {
        cityValue = '';
      }
      searchValue.belongtoProvince = proValue;
      searchValue.belongtoCity = cityValue;
      searchValue.belongtoArea = areaValue;
      searchValue.spType = "3";
    }
    Report.timeStamp = Util.getCurrentLoginUser()['user'].userId + new Date().getTime()
    $.ajax({
      type: "get",
      url: getServer() + '/fw/XCReport/getDate',
      data: searchValue,
      contentType: "application/json",
      success: function (data) {
        search_loading.close();
        $('#xreports-tips').hide();
        $('#xreports-contents').show();
        // 详查建筑物结构类型总数统计图
        Report.createBarEcharts({
          id: 'buildingStructureNum',
          title: '',
          subtitle: '总栋数（栋）：'+data.buildingNum.y.reduce((prev, cur) => prev+cur, 0),
          x: data.buildingNum.x,
          yname: '栋数',
          data: data.buildingNum.y
          /*series: [{
              type: 'bar',
              animation: false,
              itemStyle: {
                  normal: {
                      label: {
                          show: true, //开启显示
                          position: 'top', //在上方显示
                          textStyle: { //数值样式
                              color: 'black',
                              fontSize: 16
                          }
                      }
                  }
              }
          }]*/
        });
        // 详查建筑物结构类型面积统计图
        Report.createBarEcharts({
          id: 'buildingStructureArea',
          title: '',
          subtitle: '总面积（平方米）：'+data.buildingArea.y.reduce((prev, cur) => prev+cur, 0).toFixed(2),
          x: data.buildingArea.x,
          yname: '面积',
          data: data.buildingArea.y
        });
        // 房屋设施建造年代占比统计
        renderPie({id:'buildingAgeArea', data: data.buildingTimeArea, name: '面积'})
        renderPie({id:'buildingAgeNum', data: data.buildingTimeNum, name: '栋数'})
        // 房屋设施抗震设防烈度占比统计
        renderPie({id:'buildingIntensityArea', data: data.fortificationIntensityArea, name: '面积'})
        renderPie({id:'buildingIntensityNum', data: data.fortificationIntensityNum, name: '栋数'})
        /* // 位置分布统计
         Report.createPieEcharts({
             id: 'location',
             title: '',
             subtitle: '',
             legenddata: ['70s前','70s','80s','90s','00s','10s'],
             series: [
                 {
                     name: '面积',
                     data: [
                         {value: 11,name: '70s前'},
                         {value: 30,name: '70s'},
                         {value: 41,name: '80s'},
                         {value: 35,name: '90s'},
                         {value: 23,name: '00s'},
                         {value: 50,name: '10s'}
                     ]
                 },
                 {
                     name: '栋数',
                     data: [
                         {value: 51,name: '70s前'},
                         {value: 10,name: '70s'},
                         {value: 32,name: '80s'},
                         {value: 20,name: '90s'},
                         {value: 9,name: '00s'},
                         {value: 21,name: '10s'}
                     ]
                 }
             ]
         });*/
        // 砖混结构、砖石木结构外墙厚度占比统计
        renderPie({id:'brickOutWallThickArea', data: data.brickOutWallThickArea, name: '面积'})
        renderPie({id:'brickOutWallThickNum', data: data.brickOutWallThickNum, name: '栋数'})
        // 砖混结构、砖石木结构内墙厚度占比统计
        renderPie({id:'brickInWallThickArea', data: data.brickInWallThickArea, name: '面积'})
        renderPie({id:'brickInWallThickNum', data: data.brickInWallThickNum, name: '栋数'})
        // 砖混结构、砖石木结构墙体材质占比统计
        renderPie({id:'brickWallMaterialArea', data: data.brickWallMaterialArea, name: '面积'})
        renderPie({id:'brickWallMaterialNum', data: data.brickWallMaterialNum, name: '栋数'})
        // 砖混结构、砖石木结构砂浆类型占比统计
        renderPie({id:'brickMortarTypeArea', data: data.brickMortarTypeArea, name: '面积'})
        renderPie({id:'brickMortarTypeNum', data: data.brickMortarTypeNum, name: '栋数'})
        // 砖混结构、砖石木结构砂浆强度占比统计
        renderPie({id:'brickMortarStrengthArea', data: data.brickMortarStrengthArea, name: '面积'})
        renderPie({id:'brickMortarStrengthNum', data: data.brickMortarStrengthNum, name: '栋数'})
        // 砖混结构、砖石木结构屋盖类别占比统计
        renderPie({id:'brickRoofTypeArea', data: data.brickRoofTypeArea, name: '面积'})
        renderPie({id:'brickRoofTypeNum', data: data.brickRoofTypeNum, name: '栋数'})
        // 砖混结构、砖石木结构楼盖类别占比统计
        renderPie({id:'brickFloorTypeArea', data: data.brickFloorTypeArea, name: '面积'})
        renderPie({id:'brickFloorTypeNum', data: data.brickFloorTypeNum, name: '栋数'})
        // 砖混结构、砖石木结构圈梁设置占比统计
        renderPie({id:'brickJlInstallArea', data: data.brickJlInstallArea, name: '面积'})
        renderPie({id:'brickJlInstallNum', data: data.brickJlInstallNum, name: '栋数'})
        // 砖木结构外砂浆强度统计图
        renderPie({id:'brickwoodMortarStrengthArea', data: data.brickwoodMortarStrengthArea, name: '面积'})
        renderPie({id:'brickwoodMortarStrengthNum', data: data.brickwoodMortarStrengthNum, name: '栋数'})
        // 砖木结构外楼盖类别统计图
        renderPie({id:'brickwoodFloorTypeArea', data: data.brickwoodFloorTypeArea, name: '面积'})
        renderPie({id:'brickwoodFloorTypeNum', data: data.brickwoodFloorTypeNum, name: '栋数'})
        // 砖木结构外墙厚度统计图
        renderPie({id:'brickwoodOutWallThickArea', data: data.brickwoodOutWallThickArea, name: '面积'})
        renderPie({id:'brickwoodOutWallThickNum', data: data.brickwoodOutWallThickNum, name: '栋数'})
        // 砖木结构外内墙厚度统计图
        renderPie({id:'brickwoodInWallThickArea', data: data.brickwoodInWallThickArea, name: '面积'})
        renderPie({id:'brickwoodInWallThickNum', data: data.brickwoodInWallThickNum, name: '栋数'})
        // 砖木结构外墙体材质统计图
        renderPie({id:'brickwoodWallMaterialArea', data: data.brickwoodWallMaterialArea, name: '面积'})
        renderPie({id:'brickwoodWallMaterialNum', data: data.brickwoodWallMaterialNum, name: '栋数'})
        // 砖木结构外砂浆类型统计图
        renderPie({id:'brickwoodMortarTypeArea', data: data.brickwoodMortarTypeArea, name: '面积'})
        renderPie({id:'brickwoodMortarTypeNum', data: data.brickwoodMortarTypeNum, name: '栋数'})
        // 多层钢筋混凝土结构柱混凝土强度等级占比统计
        renderPie({id:'mulZhntqdLevelArea', data: data.mulZhntqdLevelArea, name: '面积'})
        renderPie({id:'mulZhntqdLevelNum', data: data.mulZhntqdLevelNum, name: '栋数'})
        /*  // 多层钢筋混凝土结构主要截面尺寸占比统计
          Report.createPieEcharts({
              id: 'mulZyzjmSize',
              title: '',
              subtitle: '',
              legenddata: ["<=300mm","300mm-400mm","400mm-600mm",">=600"],
              series: [
                  {
                      name: '面积',
                      data: data.mulZyzjmSizeArea
                  },
                  {
                      name: '栋数',
                      data: data.mulZyzjmSizeNum
                  }
              ]
          });*/
        // 多层钢筋混凝土结构最大柱间距占比统计
        renderPie({id:'mulZdzSpanArea', data: data.mulZdzSpanArea, name: '面积'})
        renderPie({id:'mulZdzSpanNum', data: data.mulZdzSpanNum, name: '栋数'})
        // 多层钢筋混凝土结构剪力墙混凝土强度等级占比统计
        renderPie({id:'mulJlqhntqdLevelArea', data: data.mulJlqhntqdLevelArea, name: '面积'})
        renderPie({id:'mulJlqhntqdLevelNum', data: data.mulJlqhntqdLevelNum, name: '栋数'})
        // 多层钢筋混凝土结构剪力墙最大间距占比统计
        renderPie({id:'mulJlqzdSpanArea', data: data.mulJlqzdSpanArea, name: '面积'})
        renderPie({id:'mulJlqzdSpanNum', data: data.mulJlqzdSpanNum, name: '栋数'})
        // 多层钢筋混凝土结构剪力墙厚度占比统计
        renderPie({id:'mulShearwellThicknessArea', data: data.mulShearwellThicknessArea, name: '面积'})
        renderPie({id:'mulShearwellThicknessNum', data: data.mulShearwellThicknessNum, name: '栋数'})
        // 多层钢筋混凝土结构屋盖类别占比统计
        renderPie({id:'mulRoofTypeArea', data: data.mulRoofTypeArea, name: '面积'})
        renderPie({id:'mulRoofTypeNum', data: data.mulRoofTypeNum, name: '栋数'})
        // 多层钢筋混凝土结构楼盖类别占比统计
        renderPie({id:'mulFloorTypeArea', data: data.mulFloorTypeArea, name: '面积'})
        renderPie({id:'mulFloorTypeNum', data: data.mulFloorTypeNum, name: '栋数'})
        // 高层结构柱混凝土强度等级占比统计
        renderPie({id:'heightZhntqdLevelArea', data: data.heightZhntqdLevelArea, name: '面积'})
        renderPie({id:'heightZhntqdLevelNum', data: data.heightZhntqdLevelNum, name: '栋数'})
        /* // 高层结构主要柱截面尺寸占比统计
         Report.createPieEcharts({
             id: 'heightZyzjmSize',
             title: '',
             subtitle: '',
             legenddata: ["<=300mm","300mm-400mm","400mm-600mm",">=600mm"],
             series: [
                 {
                     name: '面积',
                     data: data.heightZyzjmSizeArea
                 },
                 {
                     name: '栋数',
                     data: data.heightZyzjmSizeNum
                 }
             ]
         });*/
        // 高层结构最大柱间距占比统计
        renderPie({id:'heightZdzSpanArea', data: data.heightZdzSpanArea, name: '面积'})
        renderPie({id:'heightZdzSpanNum', data: data.heightZdzSpanNum, name: '栋数'})
        // 高层结构剪力墙混凝土强度等级占比统计
        renderPie({id:'heightJlqhntqdLevelArea', data: data.heightJlqhntqdLevelArea, name: '面积'})
        renderPie({id:'heightJlqhntqdLevelNum', data: data.heightJlqhntqdLevelNum, name: '栋数'})
        // 高层结构剪力墙最大间距占比统计
        renderPie({id:'heightJlqzdSpanArea', data: data.heightJlqzdSpanArea, name: '面积'})
        renderPie({id:'heightJlqzdSpanNum', data: data.heightJlqzdSpanNum, name: '栋数'})
        // 高层结构剪力墙厚度占比统计
        renderPie({id:'heightShearwellThicknessArea', data: data.heightShearwellThicknessArea, name: '面积'})
        renderPie({id:'heightShearwellThicknessNum', data: data.heightShearwellThicknessNum, name: '栋数'})
        // 高层结构屋盖类别占比统计
        renderPie({id:'heightRoofTypeArea', data: data.heightRoofTypeArea, name: '面积'})
        renderPie({id:'heightRoofTypeNum', data: data.heightRoofTypeNum, name: '栋数'})
        // 高层结构楼盖类别占比统计
        renderPie({id:'heightFloorTypeArea', data: data.heightFloorTypeArea, name: '面积'})
        renderPie({id:'heightFloorTypeNum', data: data.heightFloorTypeNum, name: '栋数'})
        // 工业厂房结构排架柱类型占比统计
        renderPie({id:'factoryBentFrameColTypeArea', data: data.factoryBentFrameColTypeArea, name: '面积'})
        renderPie({id:'factoryBentFrameColTypeNum', data: data.factoryBentFrameColTypeNum, name: '栋数'})
        // 工业厂房结构各跨跨度占比统计
        renderPie({id:'factorySpansArea', data: data.factorySpansArea, name: '面积'})
        renderPie({id:'factorySpansNum', data: data.factorySpansNum, name: '栋数'})
        // 工业厂房结构排架柱距占比统计
        renderPie({id:'factoryBentFrameColSpaceArea', data: data.factoryBentFrameColSpaceArea, name: '面积'})
        renderPie({id:'factoryBentFrameColSpaceNum', data: data.factoryBentFrameColSpaceNum, name: '栋数'})
        // 工业厂房结构屋盖体系占比统计
        renderPie({id:'factoryRoofSystemArea', data: data.factoryRoofSystemArea, name: '面积'})
        renderPie({id:'factoryRoofSystemNum', data: data.factoryRoofSystemNum, name: '栋数'})
        // 工业厂房结构屋架形式占比统计
        renderPie({id:'factoryRoofTrussStyleArea', data: data.factoryRoofTrussStyleArea, name: '面积'})
        renderPie({id:'factoryRoofTrussStyleNum', data: data.factoryRoofTrussStyleNum, name: '栋数'})
        // 工业厂房结构圈梁道数占比统计
        renderPie({id:'factoryRingBeamNumArea', data: data.factoryRingBeamNumArea, name: '面积'})
        renderPie({id:'factoryRingBeamNumNum', data: data.factoryRingBeamNumNum, name: '栋数'})
        // 空旷结构柱类型占比统计
        renderPie({id:'wideColTypePieArea', data: data.wideColTypeArea, name: '面积'})
        renderPie({id:'wideColTypePieNum', data: data.wideColTypeNum, name: '栋数'})
        // 空旷结构柱跨度占比统计
        renderPie({id:'wideColSpanArea', data: data.wideColSpanArea, name: '面积'})
        renderPie({id:'wideColSpanNum', data: data.wideColSpanNum, name: '栋数'})
        // 空旷结构柱距占比统计
        renderPie({id:'wideColSpaceArea', data: data.wideColSpaceArea, name: '面积'})
        renderPie({id:'wideColSpaceNum', data: data.wideColSpaceNum, name: '栋数'})
        // 空旷结构屋面类别占比统计
        renderPie({id:'wideWmTypeArea', data: data.wideWmTypeArea, name: '面积'})
        renderPie({id:'wideWmTypeNum', data: data.wideWmTypeNum, name: '栋数'})
        // 空旷结构屋架形式占比统计
        renderPie({id:'wideWjGenreArea', data: data.wideWjGenreArea, name: '面积'})
        renderPie({id:'wideWjGenreNum', data: data.wideWjGenreNum, name: '栋数'})
        // 空旷结构圈梁道数占比统计
        renderPie({id:'wideRingBeamArea', data: data.wideRingBeamArea, name: '面积'})
        renderPie({id:'wideRingBeamNum', data: data.wideRingBeamNum, name: '栋数'})
        // 土木结构墙体类型占比统计
        renderPie({id:'buildingWallTypeArea', data: data.buildingWallTypeArea, name: '面积'})
        renderPie({id:'buildingWallTypeNum', data: data.buildingWallTypeNum, name: '栋数'})
        //土木结构墙体延性材料占比统计
        renderPie({id:'buildingQtyxclArea', data: data.buildingQtyxclArea, name: '面积'})
        renderPie({id:'buildingQtyxclNum', data: data.buildingQtyxclNum, name: '栋数'})
        //土木结构墙体厚度占比统计
        renderPie({id:'buildingWallThickArea', data: data.buildingWallThickArea, name: '面积'})
        renderPie({id:'buildingWallThickNum', data: data.buildingWallThickNum, name: '栋数'})
        //土木结构门窗洞口宽度占比统计
        renderPie({id:'buildingWindowWidthArea', data: data.buildingWindowWidthArea, name: '面积'})
        renderPie({id:'buildingWindowWidthNum', data: data.buildingWindowWidthNum, name: '栋数'})
        //土木结构屋架材料占比统计
        renderPie({id:'buildingWmMaterialArea', data: data.buildingWmMaterialArea, name: '面积'})
        renderPie({id:'buildingWmMaterialNum', data: data.buildingWmMaterialNum, name: '栋数'})
        //土木结构墙体圈梁占比统计
        renderPie({id:'buildingWallRingBeamArea', data: data.buildingWallRingBeamArea, name: '面积'})
        renderPie({id:'buildingWallRingBeamNum', data: data.buildingWallRingBeamNum, name: '栋数'})
        //木结构穿斗方式占比统计
        renderPie({id:'woodCdTypeArea', data: data.woodCdTypeArea, name: '面积'})
        renderPie({id:'woodCdTypeNum', data: data.woodCdTypeNum, name: '栋数'})
        //木结构围护墙体类型占比统计
        renderPie({id:'woodWallTypeArea', data: data.woodWallTypeArea, name: '面积'})
        renderPie({id:'woodWallTypeNum', data: data.woodWallTypeNum, name: '栋数'})
        //土木结构木柱梢径占比统计
        renderPie({id:'woodMzsjArea', data: data.woodMzsjArea, name: '面积'})
        renderPie({id:'woodMzsjNum', data: data.woodMzsjNum, name: '栋数'})
        //土木结构山尖墙体类型占比统计
        renderPie({id:'woodSjqtTypeArea', data: data.woodSjqtTypeArea, name: '面积'})
        renderPie({id:'woodSjqtTypeNum', data: data.woodSjqtTypeNum, name: '栋数'})
        //土木结构墙体厚度占比统计
        renderPie({id:'woodWallThickArea', data: data.woodWallThickArea, name: '面积'})
        renderPie({id:'woodWallThickNum', data: data.woodWallThickNum, name: '栋数'})
        //土木结构墙体圈梁占比统计
        renderPie({id:'woodWallRingBeamArea', data: data.woodWallRingBeamArea, name: '面积'})
        renderPie({id:'woodWallRingBeamNum', data: data.woodWallRingBeamNum, name: '栋数'})
        //石木结构墙体材质占比统计
        renderPie({id:'stoneWallMaterialArea', data: data.stoneWallMaterialArea, name: '面积'})
        renderPie({id:'stoneWallMaterialNum', data: data.stoneWallMaterialNum, name: '栋数'})
        //石木结构横墙最大间距占比统计
        renderPie({id:'stoneHqzdSpaceArea', data: data.stoneHqzdSpaceArea, name: '面积'})
        renderPie({id:'stoneHqzdSpaceNum', data: data.stoneHqzdSpaceNum, name: '栋数'})
        //石木结构横墙厚度占比统计
        renderPie({id:'stoneWallThickArea', data: data.stoneWallThickArea, name: '面积'})
        renderPie({id:'stoneWallThickNum', data: data.stoneWallThickNum, name: '栋数'})
        //石木结构横墙开洞面积占比统计
        renderPie({id:'stoneHqkdAreaArea', data: data.stoneHqkdAreaArea, name: '面积'})
        renderPie({id:'stoneHqkdAreaNum', data: data.stoneHqkdAreaNum, name: '栋数'})
        //石木结构屋盖类型占比统计
        renderPie({id:'stoneRoofTypeArea', data: data.stoneRoofTypeArea, name: '面积'})
        renderPie({id:'stoneRoofTypeNum', data: data.stoneRoofTypeNum, name: '栋数'})
        //石木结构圈梁占比统计
        renderPie({id:'stoneQlArea', data: data.stoneQlArea, name: '面积'})
        renderPie({id:'stoneQlNum', data: data.stoneQlNum, name: '栋数'})
        //石木结构四角设构造柱占比统计
        renderPie({id:'stoneSjsgzzArea', data: data.stoneSjsgzzArea, name: '面积'})
        renderPie({id:'stoneSjsgzzNum', data: data.stoneSjsgzzNum, name: '栋数'})
        // 其他结构剪力墙混凝强度等级统计图
        renderPie({id:'otherJlqhntqdLevelArea', data: data.otherJlqhntqdLevelArea, name: '面积'})
        renderPie({id:'otherJlqhntqdLevelNum', data: data.otherJlqhntqdLevelNum, name: '栋数'})
        // 其他结构剪力墙最大间距统计图
        renderPie({id:'otherJlqzdSpanArea', data: data.otherJlqzdSpanArea, name: '面积'})
        renderPie({id:'otherJlqzdSpanNum', data: data.otherJlqzdSpanNum, name: '栋数'})
        // 其他结构外砂浆类型统计图
        renderPie({id:'otherMortarTypeArea', data: data.otherMortarTypeArea, name: '面积'})
        renderPie({id:'otherMortarTypeNum', data: data.otherMortarTypeNum, name: '栋数'})
        // 其他结构外砂浆类型统计图
        renderPie({id:'otherMaterialArea', data: data.otherMaterialArea, name: '面积'})
        renderPie({id:'otherMaterialNum', data: data.otherMaterialNum, name: '栋数'})
        // 其他结构外楼盖类别统计图
        renderPie({id:'otherFloorTypeArea', data: data.otherFloorTypeArea, name: '面积'})
        renderPie({id:'otherFloorTypeNum', data: data.otherFloorTypeNum, name: '栋数'})
        // 其他结构屋盖类型统计图
        renderPie({id:'otherRoofTypeArea', data: data.otherRoofTypeArea, name: '面积'})
        renderPie({id:'otherRoofTypeNum', data: data.otherRoofTypeNum, name: '栋数'})
        cb && cb()
      }
    });
  }

  var renderPie = function (config) {
    Report.createPieEcharts({
      id: config.id,
      title: '',
      subtitle: '',
      series: {
        name: config.name,
        data: config.data
      }
    });
  }

  // 导出报告
  var exportXC = function () {
    var proValue = $('#province').combobox('getText');
    var cityValue = $('#city').combobox('getText');
    var areaValue = $('#county').combobox('getText');
    var taskNameValue = $('#taskName').val();
    var searchValue = {
      belongtoProvince: '',
      belongtoCity: '',
      area: '',
      taskName: ''
    }
    searchValue.taskName = taskNameValue;

    if (proValue) {
      // if (cityValue == "全部" || cityValue == '北京市' || cityValue == '天津市' || cityValue == '上海市' || cityValue == '重庆市') {
      if (cityValue == "全部") {
        cityValue = '';
      }
      searchValue.belongtoProvince = proValue;
      searchValue.belongtoCity = cityValue;
      searchValue.area = areaValue;
    }

    // Util.alert('正在导出报告，请关注浏览器的下载内容！')
    // window.location.href = getServer() + '/fw/XCReport/exportXC?province=' + searchValue.belongtoProvince + '&city=' + searchValue.belongtoCity + '&area=' + searchValue.area + '&taskName=' + searchValue.taskName + '&timeStamp=' + Report.timeStamp;

    var search_loading = Util.loading({
      text: '正在导出报告'
    })
    search_loading.show();
    SearchData(search_loading, function(){
      Util.alert('正在导出报告，请关注浏览器的下载内容！')
      window.location.href = getServer() + '/fw/XCReport/exportXC?province=' + searchValue.belongtoProvince + '&city=' + searchValue.belongtoCity + '&area=' + searchValue.area + '&taskName=' + searchValue.taskName + '&timeStamp=' + Report.timeStamp;
    })

    /*$.ajax({
      type: "get",
      url: getServer() + '/fw/XCReport/exportXC',
      param: JSON.stringify(searchValue),
      async: "true",
      dataType: "json",
      success: function (data) {
        Util.alert('导出成功！');
      }
    })*/
  }

  var createProvince = function () {
    $('#province').combobox({
      url: "/app/divisions/root/subdivisions",
      method: 'get',
      editable: false, //不可编辑状态  
      cache: false,
      // panelHeight: 'auto',//自动高度适合  
      valueField: 'divisionId',
      textField: 'divisionName',
      onLoadSuccess: function (data) {
        $('#province').combobox('select', '');
      }
    });
    $("#province").combobox({
      onSelect: function (value) {
        var re = value.divisionId;
        var list = new Array();
        list.push({
          "divisionId": "-1",
          "divisionName": ""
        });
        if (re != null && re != '') {
          list.push(re);
        }

        if (value.divisionName == '北京市' || value.divisionName == '天津市' || value.divisionName == '上海市' || value.divisionName == '重庆市') {
          var division = [];
          division.push(value);
          $('#city').combobox('loadData', division);
          $('#city').combobox('select', value.divisionName);

          $('#county').combobox({
            url: "/app/divisions/" + value.divisionId + "/subdivisions",
            method: 'get',
            editable: false, //不可编辑状态  
            cache: false,
            //panelHeight: 'auto',//自动高度适合  
            valueField: 'divisionId',
            textField: 'divisionName',
            onLoadSuccess: function () {
              $('#county').combobox('select', list[0].divisionName);
            }
          });
        } else {
          $('#city').combobox({
            url: "/app/divisions/" + value.divisionId + "/subdivisions",
            method: 'get',
            editable: false, //不可编辑状态  
            cache: false,
            // panelHeight: 'auto',//自动高度适合  
            valueField: 'divisionId',
            textField: 'divisionName',
            onLoadSuccess: function () {
              $('#city').combobox('select', list[0].divisionName);
            }
          });
          createCity();
          $('#county').combobox('loadData', {}); //清空option选项
          $('#county').combobox('clear');
        }
      }
    });

    createCity();
    $('#county').combobox({
      data: '',
      editable: false, //不可编辑状态  
      cache: false
    });
  }

  var createCity = function () {
    $("#city").combobox({
      onSelect: function (value) {
        var re = value.divisionId;
        var list = new Array();
        list.push({
          "divisionId": "-1",
          "divisionName": ""
        });
        if (re.list != null && re.list != 'null') {
          list.push(re);
        }
        $('#county').combobox({
          url: "/app/divisions/" + value.divisionId + "/subdivisions",
          method: 'get',
          editable: false, //不可编辑状态
          cache: false,
          //panelHeight: 'auto',//自动高度适合
          valueField: 'divisionId',
          textField: 'divisionName',
          onLoadSuccess: function () {
            $('#county').combobox('select', list[0].divisionName);
          }
        });
      }
    });
  }

  return {
    init: init
  };
});